package top.tony.employee.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.tony.base.pagenation.PageModel;
import top.tony.employee.entity.Employee;
import top.tony.employee.entity.vo.EmployeeVo;
import top.tony.employee.query.EmployeeQueryObject;
import top.tony.employee.query.EmployeeVoQueryObject;
import top.tony.employee.service.EmployeeService;

import javax.annotation.Resource;

/**
 * Created by Tony_Du on 2015/12/3 0003.
 */
@RestController
public class EmployeeController {

    @Resource
    private EmployeeService employeeService;

    @RequestMapping(value = "/",method = RequestMethod.GET)
    public PageModel<Employee> test(@RequestParam int pageNo,@RequestParam int pageSize,@RequestParam String name){
        EmployeeQueryObject queryObejct=new EmployeeQueryObject();
        queryObejct.setPageNo(pageNo);
        queryObejct.setPageSize(pageSize);
        queryObejct.setName(name);
        return employeeService.pageQuery(queryObejct);
    }

    @RequestMapping(value = "/test",method = RequestMethod.GET)
    public PageModel<EmployeeVo> test1(@RequestParam int pageNo,@RequestParam int pageSize,@RequestParam String name){
        EmployeeVoQueryObject queryObejct=new EmployeeVoQueryObject();
        queryObejct.setPageNo(pageNo);
        queryObejct.setPageSize(pageSize);
        queryObejct.setName(name);
        return employeeService.voPageQuery(EmployeeVo.class,queryObejct);
    }
}
